{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.12"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3612jvsc74a57bd09e448ea22042ddd26567fb390bbbe4eeefe3b92c7642735c8d963670b078654d",
   "display_name": "Python 3.6.12 64-bit ('common': conda)"
  },
  "metadata": {
   "interpreter": {
    "hash": "9e448ea22042ddd26567fb390bbbe4eeefe3b92c7642735c8d963670b078654d"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "## 文件IO\n",
    "这一节将会介绍基本几何图形的读取和写入\n",
    "\n"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "##  点云（pcd txt）"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Testing IO for point cloud ...\nPointCloud with 7187 points.\n"
     ]
    }
   ],
   "source": [
    "import open3d as o3d   #导入open3d\n",
    "print(\"Testing IO for point cloud ...\")\n",
    "pcd = o3d.io.read_point_cloud(\"/home/hcq/python/Point-Clouds-Visualization/2open3D/data/merge_with_pedestrian1.pcd\") # 读取\n",
    "print(pcd)\n",
    "# o3d.io.write_point_cloud(\"copy_merge_with_pedestrian1.pcd\", pcd) # 写入\n"
   ]
  },
  {
   "source": [
    "## 网格（Mesh） ply"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Testing IO for meshes ...\n\u001b[1;33m[Open3D WARNING] geometry::TriangleMesh appears to be a geometry::PointCloud (only contains vertices, but no triangles).\u001b[0;m\nTriangleMesh with 134536 points and 0 triangles.\n"
     ]
    }
   ],
   "source": [
    "import open3d as o3d   #导入open3d\n",
    "\n",
    "print(\"Testing IO for meshes ...\")\n",
    "mesh = o3d.io.read_triangle_mesh(\"/home/hcq/python/Point-Clouds-Visualization/2open3D/data/conferenceRoom_1_GT.ply\")\n",
    "print(mesh)\n",
    "# o3d.io.write_triangle_mesh(\"copy_of_conferenceRoom_1_GT.ply\",mesh)"
   ]
  },
  {
   "source": [
    "## 图像（Image）\n",
    "\n",
    "不支持png"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Testing IO for images ...\nImage of size 1024x576, with 3 channels.\nUse numpy.asarray to access buffer data.\n"
     ]
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "metadata": {},
     "execution_count": 1
    }
   ],
   "source": [
    "import open3d as o3d   #导入open3d\n",
    "\n",
    "print(\"Testing IO for images ...\")\n",
    "img = o3d.io.read_image(\"/home/hcq/python/Point-Clouds-Visualization/2open3D/data/cat.jpg\")\n",
    "print(img)\n",
    "o3d.io.write_image(\"copy.jpg\", img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}